<template>
  <div class="product-detail">
    <div class="detail-content">
      <div class="detail-content-top">
        <div>
          <span class="productInfo-title">{{ productInfo.title }}</span>
          <span class="titleDepict">{{ productInfo.proCode }}</span>
        </div>
        <div class="titleDepict-right">
          <el-tooltip content="分享" placement="bottom" effect="light">
            <div class="product-share">
              <img src="../../assets/images/share-icon.svg" />
            </div>
          </el-tooltip>
          <div class="buying-price">购买</div>
        </div>
      </div>
      <div class="productInfo-main-content">
        <div class="content">
          {{ productInfo.profitDepict }} :<span>{{ productInfo.profit }}</span>
        </div>
        <div class="content">
          {{ productInfo.buyingPriceDepict }} :<span>{{
            productInfo.buyingPrice
          }}</span>
        </div>
        <div class="content">投资期限 :<span>360天</span></div>
        <div class="content">
          发行时间 :<span>{{ productInfo.proCollectBegin | gitDate }}</span>
        </div>
      </div>
    </div>
    <div class="product-show">
      <el-tabs v-model="activeName">
        <el-tab-pane label="产品详情" name="first">
          <div class="table-product">
            <span class="table-product-title">{{ productInfo.title }}</span>
            <div class="main-content" v-if="isInfo">
              <div class="row-content">
                <span>产品代码</span>
                <span class="productInfo-value">{{ productInfo.proCode }}</span>
                <span>{{ productInfo.profitDepict }}</span>
                <span class="productInfo-value">{{ productInfo.profit }}</span>
              </div>
              <div class="row-content">
                <span>{{ productInfo.buyingPriceDepict }}</span>
                <span class="productInfo-value">{{
                  productInfo.buyingPrice
                }}</span>
                <span>可否赎回</span>
                <span class="productInfo-value">{{
                  productInfo.isPublish ? "是" : "否"
                }}</span>
              </div>
              <div class="row-content">
                <span>投资期限</span>
                <span class="productInfo-value">360天</span>
                <span>发行区域</span>
                <span class="productInfo-value">全国</span>
              </div>
              <div class="row-content">
                <span>发行时间</span>
                <span class="productInfo-value">{{
                  productInfo.proCollectBegin | gitDate
                }}</span>
                <span>结束时间</span>
                <span class="productInfo-value">{{
                  productInfo.proCollectEnd | gitDate
                }}</span>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="产品说明书" name="second">
          <div class="table-product">
            <instruction></instruction>
          </div>
        </el-tab-pane>
        <el-tab-pane label="产品公告" name="third">
          <div class="table-product">
            <notice></notice>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import Notice from "./data/notice";
import Instruction from "./data/Instruction";
export default {
  name: "productDetail",
  components: {
    Notice,
    Instruction
  },
  data() {
    return {
      activeName: "first",
      isInfo: false,
      productInfo: {
        isHot: true,
        title: "易精灵1号",
        titleDepict: "1万起购 | 大众客户 | 低风险",
        profit: "3.621%",
        profitDepict: "参考年化净收益",
        buyingPrice: "1万元/1000元",
        buyingPriceDepict: "起购金额"
      }
    };
  },
  methods: {
    getProductInfo() {
      let id = window.sessionStorage.getItem("productDetailId");
      this.$remote("/runtime/pocfinancial/selectPocFinancial.action", {
        id: id
      }).then(res => {
        this.productInfo.title = res.proName;
        this.productInfo.profit = res.proProfit;
        this.productInfo.proCode = res.proCode;
        this.productInfo.proCollectBegin = res.proCollectBegin;
        this.productInfo.proCollectEnd = res.proCollectEnd;
        this.productInfo.proType = res.proType;
        this.productInfo.isPublish = res.isPublish;
        this.isInfo = true;
      });
    }
  },
  created() {
    this.getProductInfo();
  },
  filters: {
    gitDate(value) {
      value = value + "";
      let y = value.substring(0, 4);
      let m = value.substring(4, 6);
      let d = value.substring(6, 8);
      let h = value.substring(8, 10);
      let dd = value.substring(10, 12);
      return y + "-" + m + "-" + d + " " + h + ":" + dd;
    }
  }
};
</script>
<style scoped>
.product-detail {
  width: 80%;
  margin: 0px auto;
}
.detail-content {
  height: 120px;
  color: #fff;
  background-color: #06469e;
}
.detail-content-top {
  display: flex;
  height: 70px;
  align-items: center;
  justify-content: space-between;
}
.productInfo-title {
  display: inline-block;
  width: 600px;
  height: 100%;
  /*line-height: 70px;*/
  font-size: 20px;
  padding-left: 40px;
}
.titleDepict-right {
  display: flex;
  align-items: center;
}
.product-share {
  margin-right: 30px;
  display: inline-block;
  width: 30px;
  height: 30px;
}
.product-share:hover {
  cursor: pointer;
}
.product-share img {
  width: 100%;
  height: 100%;
}
.buying-price {
  display: inline-block;
  width: 80px;
  text-align: center;
  line-height: 38px;
  height: 38px;
  border: 1px solid #dedede;
  margin-right: 30px;
  border-radius: 5px;
}
.buying-price:hover {
  cursor: pointer;
}
.productInfo-main-content {
  line-height: 50px;
  padding-left: 40px;
}
.productInfo-main-content .content {
  display: inline-block;
  padding-right: 30px;
}
.productInfo-main-content .content span {
  font-size: 20px;
  display: inline-block;
  margin-left: 10px;
}
.table-product {
  height: 300px;
  width: 100%;
  border: 1px solid #dedede;
  overflow: auto;
  padding: 10px 20px;
  /*background-color: coral;*/
}
.product-show {
  width: 100%;
  margin: 40px auto;
}
.table-product-title {
  display: block;
  height: 38px;
  font-size: 20px;
  line-height: 38px;
  text-align: center;
  margin: 20px auto;
}
.product-hint {
  display: block;
  line-height: 200px;
  text-align: center;
  margin-top: 20px;
}
.main-content {
  width: 805px;
  height: auto;
  padding-bottom: 1px;
  margin: 0px auto;
  background-color: #999999;
}
.row-content span {
  display: inline-block;
  height: 38px;
  line-height: 38px;
  width: 200px;
  padding-left: 20px;
  background-color: #e7e7e7;
  margin-top: 1px;
  margin-left: 1px;
}
.productInfo-value {
  background-color: #fdfdfe !important;
}
</style>
